package 剑指offer;

import jdk.jfr.StackTrace;
import org.junit.Test;

public class 二进制中一的个数 {
    public int hammingWeight(int n) {
        String s = Integer.toBinaryString(n);
        int num=0;
        for (int i = 0; i < s.length(); i++) {
            if (s.charAt(i)=='1')
                num++;
        }
        return num;
    }
    @Test
    public void test(){
        hammingWeight(90);
    }

}
